package com.yx.shop.service.impl;

import com.yx.shop.dao.ItemDao;
import com.yx.shop.dao.impl.ItemDaoImpl;
import com.yx.shop.entitly.Item;
import com.yx.shop.service.ItemService;
import com.yx.shop.utils.JDBCUtils;

/**
 * @Classname ItemServiceImpl
 * @Description TODO:
 * @Date 2021/05/09 14:00
 * @Created by yx
 */
public class ItemServiceImpl implements ItemService {
    private ItemDao itemDao = new ItemDaoImpl();
    @Override
    public boolean addItem(Item item) {
        boolean flag = false;
        try {
            JDBCUtils.begin();
            if (item!=null){
                if (itemDao.addItem(item)>0){
                    flag=true;
                }
            }
            JDBCUtils.commit();
        } catch (Exception e) {
            JDBCUtils.rollback();
            e.printStackTrace();
        }
        return flag;
    }
}
